package edu.sctu.xialei.May.day20150517two;


/**
 * Created by Administrator on 2015/5/17 0017.
 */
public class TextChilds {

   public void printing (DatasOfStudents[] datas){

       System.out.println("*****总体情况*****");

       for (int i = 0; i < datas.length ; i++) {

           System.out.println("姓名："+ datas[i].name + "  年龄： " + datas[i].age);
       }
   }


    ComparingByAge comparing_by_age = new ComparingByAge() {
        @Override
        public DatasOfStudents[] compare() {

            ValueToSetting value_to_setting = new ValueToSetting();

            DatasOfStudents[]population_Behave_18 = new DatasOfStudents[value_to_setting.num_Of_Student];

            int counter = 0;

            for (int i = 0; i < value_to_setting.setting().length; i++) {

                if(value_to_setting.setting()[i].age > 18){

                    population_Behave_18[counter] = value_to_setting.setting()[i];

                    counter++;
                }
            }
            return population_Behave_18;
    }
    };

    public DatasOfStudents[] comparing(ComparingByAge comparing_by_age){
        return  (comparing_by_age.compare());
    }

    public void output(DatasOfStudents[]datas_of_students){
        int counter = 0;

        System.out.println("*****成年情况*****");

        for (int i = 0; i < datas_of_students.length; i++) {
            if(datas_of_students[i] == null){
                break;
            }

            counter++;
            System.out.println("姓名：" + datas_of_students[i].name + "   年龄：" + datas_of_students[i].age);
        }

        System.out.println("成年人数：" + counter);
    }
}
